Use case: CEC transmit IT mode ¶
This use case describes how to transmit a CEC frame in Interrupt mode (IT mode) using HAL1 and HAL2.
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
CEC_HandleTypeDef hcec;
uint8_t Tab_Tx[2];
uint8_t DestinationAddress;
uint8_t InitiatorAddress;
uint32_t TxSize = 0X02;
hcec.Instance = CEC;
hcec.Init.OwnAddress = CEC_OWN_ADDRESS_1;
HAL_CEC_Init(&hcec);
InitiatorAddress = 0x1;
DestinationAddress = 0x3;
Tab_Tx[0] = 0x44;
Tab_Tx[1] = 0x42;
HAL_CEC_Transmit_IT(&hcec, InitiatorAddress, DestinationAddress, (uint8_t *)&Tab_Tx, TxSize);
|
hal_cec_handle_t hcec;
uint8_t tx_data_frame[2];
hal_cec_header_t tx_header;
hal_cec_header_t p_rx_header;
uint8_t rx_data_frame[2];
uint32_t max_size_byte = 0x02;
uint32_t tx_size = 0x02;
hal_cec_config_t config;
HAL_CEC_Init(&hcec, HAL_CEC);
config.own_address = HAL_CEC_OWN_ADDR_1;
HAL_CEC_SetConfig(&hcec, &config);
/* Start CEC in IT mode to enable the peripheral */
HAL_CEC_Start_IT(&hcec, &p_rx_header, rx_data_frame, max_size_byte);
tx_header.initiator_address = 0x1;
tx_header.destination_address = 0x3;
tx_data_frame[0] = 0x44;
tx_data_frame[1] = 0x42;
HAL_CEC_Transmit_IT(&hcec, &tx_header, tx_data_frame, tx_size);
|
Key changes ¶
HAL2 separates initialization from configuration using
HAL_CEC_InitthenHAL_CEC_SetConfig.HAL2 requires starting the peripheral in IT mode using
HAL_CEC_Start_ITbefore transmitting.HAL2 uses typed configuration and header structures (for example
hal_cec_config_tandhal_cec_header_t) instead of passing raw addressing parameters.

